package com.jd.exception;

import com.jd.utils.JDJSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

@RestControllerAdvice
public class CustomExceptionHandler {


    //上传文件超过500k，捕获异常MaxUploadSizeExceededException
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public JDJSONResult  handlerMaxUploadFile(MaxUploadSizeExceededException excption){
        return JDJSONResult.errorMsg("文件上传大小不能超过500kb，请压缩图片或者降低图片质量再上传");
    }
}
